package lab.gene.action;

import java.util.Date;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lab.gene.service.impl.GeneSecondStagePCRServiceImpl;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;

public class UpdateGeneSecondStagePCRAction extends ActionSupport implements ServletResponseAware, ServletRequestAware{
	
	private static final long serialVersionUID = 1L;
	private Date recordDate = null;
	private Integer ml1;
	private Integer ml2;
	private Integer volume1;
	private Integer volume2;
	private String comments = null;
	private String geneName = null;
	private String stepType = null;
	private String username = null;
	
	protected HttpServletResponse servletResponse;  
	@Override   
	public void setServletResponse(HttpServletResponse servletResponse) {   
		this.servletResponse = servletResponse;   
	}   
	
	protected HttpServletRequest servletRequest;   
	@Override   
	public void setServletRequest(HttpServletRequest servletRequest) {   
		this.servletRequest = servletRequest;   
	}
	
	public String execute() {
		Cookie[] cookies = servletRequest.getCookies();
		String cookieName = "LabUser";
		if (cookies != null) {
			for (int i = 0; i < cookies.length; i++) {
				if (cookies[i].getName().equals(cookieName)) {
					username = cookies[i].getValue();
					break;
				}
			}
		}

		GeneSecondStagePCRServiceImpl service = new GeneSecondStagePCRServiceImpl();
		service.addGeneSecondStagePCR(geneName, username, stepType, volume1, volume2, ml1, ml2, recordDate, comments);
		
		return "success";
		
	}

	public Date getRecordDate() {
		return recordDate;
	}

	public void setRecordDate(Date recordDate) {
		this.recordDate = recordDate;
	}

	public Integer getMl1() {
		return ml1;
	}

	public void setMl1(Integer ml1) {
		this.ml1 = ml1;
	}

	public Integer getMl2() {
		return ml2;
	}

	public void setMl2(Integer ml2) {
		this.ml2 = ml2;
	}

	public Integer getVolume1() {
		return volume1;
	}

	public void setVolume1(Integer volume1) {
		this.volume1 = volume1;
	}

	public Integer getVolume2() {
		return volume2;
	}

	public void setVolume2(Integer volume2) {
		this.volume2 = volume2;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public String getGeneName() {
		return geneName;
	}

	public void setGeneName(String geneName) {
		this.geneName = geneName;
	}

	public String getStepType() {
		return stepType;
	}

	public void setStepType(String stepType) {
		this.stepType = stepType;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}
	
	

}
